package com.sunsys.cxf.java_first_jaxws_client;

import java.util.Map;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.sunsys.examples.cxf.server.HelloWorld;
import com.sunsys.examples.cxf.server.User;
import com.sunsys.examples.cxf.server.UserImpl;

public class JavaFirstJaxwsClient {

	public static void main(String []args) {
		
        ClassPathXmlApplicationContext context 
        = new ClassPathXmlApplicationContext(new String[] {"client-beans.xml"});

		HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorld");
		
		String reply = helloWorld.sayHi("Hi This is Java FIrst Jaxws web service client");
		System.out.println("reply :"+reply);
		
		User user = new UserImpl("Ravi");
		
		reply = helloWorld.sayHiToUser(user);
		System.out.println("Reply2:"+reply);
		
        System.out.println("Users: ");
        Map<Integer, User> users = helloWorld.getUsers();
        for (Map.Entry<Integer, User> e : users.entrySet()) {
            System.out.println("  " + e.getKey() + ": " + e.getValue().getName());
        }

		System.out.println("Thank you");

	}
}
